package com.hx.zhg.service.quartz;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.hx.zhg.service.annotation.Task;
import com.hx.zhg.service.system.WxSystemService;
import com.hx.zhg.service.utils.SpringUtil;
import org.apache.log4j.Logger;

/**
 * 定时定时刷新微信ACCESS_TOKEN
 * Created by zhenghegong on 2020/4/18.
 */
@Task(jobName = "wxFlushAccessToken", cron = "0 0 0/2 * * ? ", desc = "WxFlushAccessToken")
public class WxFlushAccessTokenJob implements SimpleJob {

    private static final Logger log = Logger.getLogger(WxFlushAccessTokenJob.class);

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("【*】开始执行定时刷新微信ACCESS_TOKEN任务");
        try {
            String jobParameter = shardingContext.getJobParameter();
            System.out.println(jobParameter);
            WxSystemService wxSystemService = SpringUtil.getBean("wxSystemService");
            wxSystemService.flushAccessToken();
        } catch (Exception e) {
            log.error(String.format("【*】执行定时刷新微信ACCESS_TOKEN任务,异常，%s", e));
        }
    }
}
